<%@ page contentType="text/html; charset=utf-8" language="java" %>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="epopos" uri="http://www.shengruan.com/taglib"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<link href="../style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/admin/assets/js/util.js"></script>
<script type="text/javascript" src="/assets/js/dojo/dojo.js"></script>
<script language="javascript">
dojo.require("dojo.io.*");
function check()
{
	var maxConn = document.getElementById("maxPoolConn");
	if(maxConn.value=="")
	{
		OS.showWarming("errorTd","请输入最大连接的数量！");
		maxConn.focus();
		return false;
	}
	else
	{
		OS.hideWarming("errorTd");
	}
	if(maxConn.value<5||maxConn.value>200)
	{
		OS.showWarming("errorTd","连接池的最大连接数的范围为5~200！");
		maxConn.focus();
		return false;
	}
	else
	{
		OS.hideWarming("errorTd");
	}

	document.getElementById("sureButton").disabled = true;
	dojo.io.bind({
			url: "dataBase.do?method=updateConnPool",
			formNode:dojo.byId("connPoolForm"),
			mimetype:"text/html",
			method:"POST",
			encoding:"UTF-8",
			timeout:10000, 
			preventCache:true,
			load: function(type, data, evt){
				OS.showCue("errorTd","设置成功!");
				document.getElementById("sureButton").disabled = false;
			
			},
			error: function(type, error){
				
			},
			timeout: function(type, data, evt){
				
			}
		});
		return false;
}
function closeConn()
{
	dojo.io.bind({
			url: "dataBase.do?method=closePoolConn",
			formNode:dojo.byId("connPoolForm"),
			mimetype:"text/html",
			method:"POST",
			encoding:"UTF-8",
			timeout:10000, 
			preventCache:true,
			load: function(type, data, evt){
				OS.showCue("errorTd","释放成功!");
				document.getElementById("enableConnTd").innerHTML = 1;
			
			},
			error: function(type, error){
				
			},
			timeout: function(type, data, evt){
				
			}
		});
		return false;
}

function getConnInfo()
{
	dojo.io.bind({
			url: "dataBase.do?method=getPoolInfo",
			mimetype:"text/html",
			method:"POST",
			encoding:"UTF-8",
			timeout:10000, 
			preventCache:true,
			load: function(type, data, evt){
				var msg = data.split("||");
				document.getElementById("usingConnTd").innerHTML = msg[0];
				document.getElementById("enableConnTd").innerHTML = msg[1];

			},
			error: function(type, error){
				
			},
			timeout: function(type, data, evt){
				
			}
		});
		return false;
}
window.onload = function()
{
	var myInter = setInterval("getConnInfo()",1000);
}
</script>
</head>
<body class="main">
<form method="post" name="connPoolForm" id="connPoolForm" action="" onSubmit="return check()" >
<table class="container" cellpadding="0" cellspacing="0">
<tr><td>
<table class="dialog" align="center" cellpadding="0" cellspacing="0" width="400">
<tr>
<td>
    <table class="header" cellpadding="0" cellspacing="0">
    <tr>
    <td>连接池设置</td>
    </tr>
    </table>
</td>
</tr>
<tr>
<td>
    <table class="body" cellpadding="0" cellspacing="0">
        <tr>
          <td colspan="2" align="center" id="errorTd">&nbsp;</td>
          </tr>
        <tr>
          <td width="34%" height="25" align="right"><b>最大连连接数：</b></td>
          <td width="66%" height="25"><input name="maxPoolConn" type="text" id="maxPoolConn"  onKeyUp="value=value.replace(/[^0-9]/g,'')" value="${requestScope.maxConn}" size="6" maxlength="6"/></td>
        </tr>
        <tr>
          <td height="25" align="right"><strong>正在使用的连接数：</strong></td>
          <td height="25" id="usingConnTd">${requestScope.usingConn}</td>
        </tr>
        <tr>
          <td height="25" align="right"><strong>可用的空闲连接数：</strong></td>
          <td height="25" id="enableConnTd">${requestScope.enableConn}</td>
        </tr>
        <tr>
          <td colspan="2" align="left">&nbsp;</td>
          </tr>
    </table>
</td>
</tr>
<tr>
<td>
    <table class="footer" cellpadding="0" cellspacing="0">
    <tr>
    <td>
    <input class="button" id="sureButton" type="submit" value="确定"/> &nbsp;
    <input class="button" id="relButton" type="button" value="释放空闲连接" onClick="closeConn()"/>
    </tr>
    </table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
